<?php

/**
 * cmsField filter form base class.
 *
 * @package    cms
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BasecmsFieldFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'tab'          => new sfWidgetFormFilterInput(),
      'col'          => new sfWidgetFormFilterInput(),
      'relation'     => new sfWidgetFormFilterInput(),
      'value'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'max_length'   => new sfWidgetFormFilterInput(),
      'type_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('cmsFieldType'), 'add_empty' => true)),
      'subtype'      => new sfWidgetFormFilterInput(),
      'menu_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('cmsFieldMenu'), 'add_empty' => true)),
      'allow_search' => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'allow_header' => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'allow_row'    => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'allow_form'   => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'allow_show'   => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'is_controle'  => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'is_active'    => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'position'     => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'tab'          => new sfValidatorPass(array('required' => false)),
      'col'          => new sfValidatorPass(array('required' => false)),
      'relation'     => new sfValidatorPass(array('required' => false)),
      'value'        => new sfValidatorPass(array('required' => false)),
      'max_length'   => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'type_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('cmsFieldType'), 'column' => 'id')),
      'subtype'      => new sfValidatorPass(array('required' => false)),
      'menu_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('cmsFieldMenu'), 'column' => 'id')),
      'allow_search' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'allow_header' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'allow_row'    => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'allow_form'   => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'allow_show'   => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'is_controle'  => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'is_active'    => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'position'     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('cms_field_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'cmsField';
  }

  public function getFields()
  {
    return array(
      'id'           => 'Number',
      'tab'          => 'Text',
      'col'          => 'Text',
      'relation'     => 'Text',
      'value'        => 'Text',
      'max_length'   => 'Number',
      'type_id'      => 'ForeignKey',
      'subtype'      => 'Text',
      'menu_id'      => 'ForeignKey',
      'allow_search' => 'Boolean',
      'allow_header' => 'Boolean',
      'allow_row'    => 'Boolean',
      'allow_form'   => 'Boolean',
      'allow_show'   => 'Boolean',
      'is_controle'  => 'Boolean',
      'is_active'    => 'Boolean',
      'position'     => 'Number',
    );
  }
}
